Move list-contradiction NeverType out of unsetOffset into tryRemove#5707
Merged
Conversation
…ove`
`unsetOffset` is a "what does this array look like after unsetting X?"
operation — its result is always still an array. The three identical
`elseif ($this->isList->yes() && $newIsList->no()) { return new NeverType(); }`
returns sprinkled through the three branches were subtraction semantics
leaking up from the only two callers that pass
`preserveListCertainty = true`: the `HasOffsetType` and `HasOffsetValueType`
arms of `tryRemove`.
Push that check up to its actual home in `tryRemove`. The unset branches
now consistently return the post-unset shape; `tryRemove` decides on its
own that "definitely-a-list minus a definitely-present key = empty set"
and returns `NeverType` for that one case. Behaviour is preserved (full
test suite green).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unsetOffsetis a "what does this array look like after unsetting X?" operation — its result should always still be an array.elseif ($this->isList->yes() && $newIsList->no()) { return new NeverType(); }returns insideunsetOffsetwere subtraction semantics leaking up from the only two callers that passpreserveListCertainty = true: theHasOffsetTypeandHasOffsetValueTypearms oftryRemove.tryRemove, where it correctly expresses "definitely-a-list minus a definitely-present key = empty set".unsetOffsetnow consistently returns the post-unset shape across all three of its branches.Behaviour is preserved — full test suite green.
Test plan
make tests— 12,156 tests pass🤖 Generated with Claude Code